import dash
from dash import html
import feffery_antd_components as fac


class CustomDash(dash.Dash):
    """
    对Dash()进行改造，将serve_locally=False时所有js静态资源
    的原生unpkg地址用国内高速的饿了么cdn资源代替
    """

    def interpolate_index(self, **kwargs):
        scripts = kwargs.pop('scripts').replace('https://unpkg.com/', 'http://npm.elemecdn.com/')
        return super(CustomDash, self).interpolate_index(scripts=scripts, **kwargs)


app = CustomDash(
    __name__,
    serve_locally=False  # 必须设置为False
)

app.layout = html.Div(
    fac.AntdAlert(
        message='示例',
        showIcon=True
    ),
    style={
        'padding': '50px'
    }
)

if __name__ == '__main__':
    app.run_server()
